#ifndef _microMessage_H_
#define _microMessage_H_

#include "stdint.h"
#include "microRtosConfig.h"


/* FIFO类型 */
#define MR_MESSAGE_TYPE_FIFO    0
/* LIFO类型 */
#define MR_MESSAGE_TYPE_LIFO    1


/* 消息控制块 */
typedef struct MrMessageStruct{
    MrListType listRead;        /* 读取挂载节点 */
    MrListType listSend;        /* 发送挂载节点 */

    uint8_t *pIndexHead;        /* 缓存头部指针 */
    uint8_t *pIndexTail;        /* 缓存尾部指针 */
    uint8_t *pIndexNow;         /* 当前操作指针 */
    uint8_t *pIndexRead;        /* 出队索引 */
    uint8_t *pIndexSend;        /* 入队索引 */

    uint16_t size;              /* 元素大小 */
    uint16_t type;              /* 类型 */
}MrMessageType;


int8_t cMrMessageCreate(MrMessageType **pptypeMessage, uint16_t usType, uint16_t usSize, uint32_t uiLengthTotal, uint32_t uiLengthInit);
int8_t cMessageRead(MrMessageType *ptypeMessage, void *pvValue, int64_t lTick);
int8_t cMessageSend(MrMessageType *ptypeMessage, void *pvValue, int64_t lTick);


#endif
